package com.wodsy.phoenix.dataservice.payc.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.wodsy.phoenix.datadao.base.IBaseDao;
import com.wodsy.phoenix.datadao.payc.dao.PayWaterDao;
import com.wodsy.phoenix.datadao.payc.dao.TradeQuotationDao;
import com.wodsy.phoenix.dataobject.base.PhoenixResponseWrapper;
import com.wodsy.phoenix.dataobject.base.ResponseCodeConstants;
import com.wodsy.phoenix.dataobject.payc.model.PayWater;
import com.wodsy.phoenix.dataobject.payc.model.PayWaterUpdateMsg;
import com.wodsy.phoenix.dataobject.payc.model.TradeQuotation;
import com.wodsy.phoenix.dataobject.payc.vo.PayOrderReq;
import com.wodsy.phoenix.dataobject.payc.vo.PayReq;
import com.wodsy.phoenix.dataobject.payc.vo.PayStatusReq;
import com.wodsy.phoenix.dataservice.base.AbstractBaseService;
import com.wodsy.phoenix.dataservice.payc.alipay.AliPayHelpHandler;
import com.wodsy.phoenix.dataservice.payc.service.PayService;
import com.wodsy.phoenix.dataservice.payc.util.Messages;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.transaction.annotation.Transactional;

import javax.jms.*;
import java.util.Date;

/**
 * 支付中心service
 */
@Service(interfaceName = "com.wodsy.phoenix.dataservice.payc.service.PayService")
public class PayServiceImpl  extends AbstractBaseService<PayWater, Long> implements PayService {
    @Autowired
    private TradeQuotationDao tradeQuotationDao;
    @Autowired
    private PayWaterDao payWaterDao;
    @Autowired
    private JmsTemplate jmsTemplate;
    @Autowired
    private Topic topic;

    @Override
    protected IBaseDao<PayWater, Long> getIBaseDao() {
        return payWaterDao;
    }

    @Override
    public String saveOrderPayMoneyPartnerTrade(PayOrderReq payOrderReq){
        String payInfo = null;
        logger.info("1111133333");
        try {
            if (payOrderReq.getPayChannel()==1)
            {//联动优势

            }
            else if (payOrderReq.getPayChannel()==2)
            {
                /****支付宝-即时到帐*****/
                AliPayHelpHandler alipay = new AliPayHelpHandler();
                String wodsyAccount = new String(Messages.getString("wodsyAccount").getBytes("ISO-8859-1"),"UTF-8");
                payInfo = alipay.alipayFormPartnerTrade(wodsyAccount,"000111","1.11");
            }
            else if (payOrderReq.getPayChannel()==3)
            {//银联

            }
            else
            {
                logger.info("payError");
            }
        }
        catch (Exception e)
        {
           e.printStackTrace();
            logger.error("payError");
        }


        return payInfo;
    }



    public static void main(String[] args) {
        com.alibaba.dubbo.container.Main.main(args);
    }

}
